package com.disgruntledbots;

import org.andengine.extension.physics.box2d.PhysicsWorld;
import org.andengine.opengl.texture.region.ITextureRegion;
import org.andengine.opengl.vbo.VertexBufferObjectManager;

public class PhysicsEntityConnectorFactory {

	VertexBufferObjectManager vertexBuffer;
	PhysicsWorld pWorld;
	SpriteLoader loader;
	
	int basicBotCount;
	int bombBotCount;
	int empBotCount;
	
	int energyBlockCount;
	int glassBlockCount;
	int plasticBlockCount;
	int stoneBlockCount;
	
	public PhysicsEntityConnectorFactory(
			VertexBufferObjectManager vbom, PhysicsWorld physicsWorld, SpriteLoader spriteLoader)
	{
		this.pWorld = physicsWorld;
		this.vertexBuffer = vbom;
		this.loader = spriteLoader;
		
		 basicBotCount = 0;
		 bombBotCount = 0;
		 empBotCount = 0;
		
		 energyBlockCount = 0;
		 glassBlockCount = 0;
		 plasticBlockCount = 0;
		 stoneBlockCount = 0;
	}
	
	public PhysicsEntityConnector newPhysicsEntityConnector(float X, float Y, ITextureRegion texture, 
			float mass, float elasticity, float friction)
	{
		return new PhysicsEntityConnector(X, Y, texture, vertexBuffer, pWorld, mass, elasticity, friction);
	}
	
	public CircularBodyEntityConnector newCircularBodySpriteConnector(float X, float Y, ITextureRegion texture, 
			float mass, float elasticity, float friction)
	{
		return new CircularBodyEntityConnector(X, Y, texture, vertexBuffer, pWorld, mass, elasticity, friction);
	}
	
	public DamageablePhysicsEntity newBasicBot(float X, float Y)
	{
		DamageablePhysicsEntity entity = new DamageablePhysicsEntity(X, Y, loader.basicBotTxtrRegion, vertexBuffer, pWorld, 20f, .75f, .15f);
		this.basicBotCount++;
		entity.setAttributes("BasicBot" + this.basicBotCount, Integer.MAX_VALUE, 0, 100f);
		entity.mBody.setAngularVelocity(1.0f);
		return entity;
	}
	
	public DamageablePhysicsEntity newBombBot(float X, float Y)
	{
		DamageablePhysicsEntity entity = new DamageablePhysicsEntity(X, Y, loader.bombBotTxtrRegion, vertexBuffer, pWorld, 32.5f, .25f, .3f);
		this.bombBotCount++;
		entity.setAttributes("BombBot" + this.bombBotCount, Integer.MAX_VALUE, 0, 100f);
		entity.mBody.setAngularVelocity(.05f);
		return entity;
	}
	
	public DamageablePhysicsEntity newEMPBot(float X, float Y)
	{
		DamageablePhysicsEntity entity = new DamageablePhysicsEntity(X, Y, loader.empBotTxtrRegion, vertexBuffer, pWorld, 15.5f, .5f, .1f);
		this.empBotCount++;
		entity.setAttributes("EMPBot" + this.empBotCount, Integer.MAX_VALUE, 0, 100f);
		entity.mBody.setAngularVelocity(1.25f);
		return entity;
	}
	
	public DamageablePhysicsEntity newEnergyBlock(float X, float Y)
	{
		DamageablePhysicsEntity entity = new DamageablePhysicsEntity(X, Y, loader.energyBlockTxtrRegion, vertexBuffer, pWorld, 2f, .25f, .05f);
		this.energyBlockCount++;
		entity.setAttributes("EnergyBlock" + this.energyBlockCount, 100, 100, 0.8f);
		return entity;
	}
	
	public DamageablePhysicsEntity newGlassBlock(float X, float Y)
	{
		DamageablePhysicsEntity entity = new DamageablePhysicsEntity(X, Y, loader.glassBlockTxtrRegion, vertexBuffer, pWorld, 10f, .1f, .1f);
		this.glassBlockCount++;
		entity.setAttributes("BasicBot" + this.glassBlockCount, 100, 100, 0.5f);
		return entity;
	}
	
	public DamageablePhysicsEntity newPlasticBlock(float X, float Y)
	{
		DamageablePhysicsEntity entity = new DamageablePhysicsEntity(X, Y, loader.plasticBlockTxtrRegion, vertexBuffer, pWorld, 7.5f, .3f, .1f);
		this.plasticBlockCount++;
		entity.setAttributes("BasicBot" + this.plasticBlockCount, 100, 100, 1.5f);
		return entity;
	}
	
	public DamageablePhysicsEntity newStoneBlock(float X, float Y)
	{
		DamageablePhysicsEntity entity = new DamageablePhysicsEntity(X, Y, loader.stoneBlockTxtrRegion, vertexBuffer, pWorld, 7.5f, 0.5f, .25f);
		this.stoneBlockCount++;
		entity.setAttributes("BasicBot" + this.stoneBlockCount, 100, 100, 1.5f);
		return entity;
	}
}
